/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import { Image } from 'antd';
import React, { useState } from 'react';

const PreviewImage: React.FC<{ src?: any }> = (props) => {
  const { children, src } = props;
  const [visible, setVisible] = useState<boolean>(false);
  return (
    <>
      <div onClick={() => setVisible(true)}>{children}</div>
      <div style={{ display: 'none' }}>
        <Image
          // width={200}
          style={{ display: 'none' }}
          src={src}
          preview={{
            visible,
            src: src,
            onVisibleChange: (value) => {
              setVisible(value);
            },
          }}
        />
      </div>
    </>
  );
};

export default PreviewImage;
